package com.tarena.day02_all;
/**
 * Integer 是Java API 提供的包装类, 提供 整数处理的工具方法
 * Integer.toBinaryString(n) 将整数转换为 二进制字符串
 */
public class Demo02 {
  public static void main(String[] args) {
    int n = 222;
    // f(g(x)) 
    System.out.println(Integer.toBinaryString(n)); 
    
    System.out.println(~-4);//3  -n = ~n + 1 
    // ~n = -n - 1
    System.out.println(~4);//-5 
    System.out.println(~100);
    
    System.out.println(Integer.toBinaryString(-129)); 
    System.out.println(Integer.toBinaryString(-128)); 
    System.out.println(Integer.toBinaryString(-10)); 
    System.out.println(Integer.toBinaryString(-9)); 
    System.out.println(Integer.toBinaryString(-2));
    System.out.println(Integer.toBinaryString(-1)); 
    System.out.println(Integer.toBinaryString(0));
    System.out.println(Integer.toBinaryString(1)); 
    System.out.println(Integer.toBinaryString(2)); 
    System.out.println(Integer.toBinaryString(128)); 
    System.out.println(Integer.toBinaryString(129));
    //0x 是16进制的前缀
    int max = 0x7fffffff;
    System.out.println(max); 
    System.out.println(Integer.toBinaryString(max)); 
    int i = 0xffffffff;// ? -1
    System.out.println(i); //-1
    System.out.println(Integer.toBinaryString(i)); 
    //写出  -2 和 min
    i = 0xfffffffe;
    int min = 0x80000000;
    System.out.println(min); 
    System.out.println(Integer.toBinaryString(min)); 
    
  }
}
 



